package com.briup.es.web.controller;

import com.briup.es.config.response.Result;
import com.briup.es.domain.dto.OrderPayDTO;
import com.briup.es.domain.dto.PaySuccessDTO;
import com.briup.es.service.OrderPayService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
@RequiredArgsConstructor
public class OrderPayController {

    private final OrderPayService orderPayService;

    @PutMapping("/pay")
    public Result<String> orderPay(@RequestBody @Valid OrderPayDTO payDTO){
        String result = orderPayService.orderPay(payDTO);
        return Result.success(result);
    }

    @PutMapping("/paySuccess")
    public Result<?> paySuccess(@RequestBody @Valid PaySuccessDTO successDTO){
        orderPayService.paySuccess(successDTO);
        return Result.success();
    }
}
